package com.tz.fruit.listener;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

/**
 * 把项目路径path放入application作用域
 */
@WebListener
public class CreatePathListener implements ServletContextListener{

	@Override
	public void contextInitialized(ServletContextEvent sce) {
		ServletContext sc = sce.getServletContext();
		String path = sc.getContextPath();
		sc.setAttribute("path", path);
	}

	@Override
	public void contextDestroyed(ServletContextEvent sce) {
		
	}

}
